//package com.onetech.adrewards.free.activities;
//
//import java.util.List;
//
//import android.app.Activity;
//import android.content.Intent;
//import android.os.AsyncTask;
//import android.os.AsyncTask.Status;
//import android.os.Bundle;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.view.View.OnClickListener;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//
//import com.fedorvlasov.lazylist.ImageLoaderWithSize;
//import com.google.analytics.tracking.android.EasyTracker;
//import com.google.analytics.tracking.android.Fields;
//import com.google.analytics.tracking.android.MapBuilder;
//import com.onetech.adrewards.free.R;
//import com.onetech.adrewards.free.activities.HomeActivity;
//import com.onetech.adrewards.free.activities.InviteFriendsActivity;
//import com.onetech.adrewards.free.adapters.ExchangeListAdapter;
//import com.onetech.adrewards.free.adapters.ListExchangeAdapter;
//import com.onetech.adrewards.free.adapters.ListGiftCardAdapter;
//import com.onetech.adrewards.free.config.AppConfig;
//import com.onetech.adrewards.free.config.AppConfig.Cache;
//import com.onetech.adrewards.free.customviews.LoadMoreListView;
//import com.onetech.adrewards.free.customviews.LoadMoreListView.OnLoadMoreListener;
//import com.onetech.adrewards.free.dialogs.ExchangeSelectDialog;
//import com.onetech.adrewards.free.fragments.BaseFragment;
//import com.onetech.adrewards.free.models.CommonModel;
//import com.onetech.adrewards.free.models.GiftCardModel;
//import com.onetech.adrewards.free.models.ListGiftCardModel;
//import com.onetech.adrewards.free.models.PointHistoryModel;
//import com.onetech.adrewards.free.objects.ListGiftCardDTO;
////import com.onetech.adrewards.free.objects.ExchangeGiftCarInfoDTO;
////import com.onetech.adrewards.free.objects.PointHistoryDTO;
//import com.onetech.adrewards.free.objects.SlideDTO;
//import com.onetech.adrewards.free.utils.AdrewadsUtils;
//import com.todddavies.components.progressbar.ProgressWheel;
//
//public class ExchangeActivity extends BaseActivity implements OnLoadMoreListener{
//	private LinearLayout mExchangeActivity = null;
//	private LinearLayout mExchangeHistory = null;
//	private LinearLayout mExchangePointHistory = null;
//	
//	private ListGiftCardAdapter mAdapter;
//	protected LoadMoreListView mListView;
//	protected View mNotFoundData=null;
//	protected int pageNo=1;
//	protected int userCoins;
//	protected View mWaitingForLoading=null;
//	//private LoadGiftCardUserExchanged mLoadGiftCardUserExchange = null;
//	private LoadListGiftCard mLoadListGiftCard = null;
//	
//	private View mBtnRetry=null;
//	private ProgressWheel mProgress=null;
//	
//	private View mExchangeContainer = null;
//	private View mGetCoinContainer = null;
//	private TextView mExchangeMessage = null;
//	private TextView mGetCoinMessage = null;
//	private View mExchangeBtn = null;
//	private View mGetCoiBtn = null;
//	private ExchangeHandler mExchangeHandle = null;
//	//private View mExchangeNoHistoryView = null;
//	
//	
//	
//	
//	public interface ExchangeHandler {
//		public void reLoadFragment(boolean isReloadUserInfo,
//				boolean isReloadExchangeHistory, boolean isCheckUserCoins);
//	}
//	
//	@Override
//	protected void onCreate(Bundle arg0) {
//		super.onCreate(arg0);
//		setMainView(R.layout.exchange_activity_layout);
//		setAppTittle(getString(R.string.invite_friend_title));
//		initView();
//		initListener();
//		 changeMenu();
//	}
//	@Override
//	protected void onResume() {
//		super.onResume();
//		if (mAdapter != null) {
//			loadListGiftCard();
//		}
//		
//	}
//	private void initView() {
//		mExchangeActivity = (LinearLayout)findViewById(R.id.exchangeActivity);
//		mExchangeHistory = (LinearLayout)findViewById(R.id.exchangeHistory);
//		mExchangePointHistory = (LinearLayout)findViewById(R.id.exchangePointHistory);
//		
//		
//		
//
//		mExchangeContainer = (LinearLayout)findViewById(R.id.exchangeContainer);
//		mGetCoinContainer = (LinearLayout)findViewById(R.id.getCoinContainer);
//		mExchangeMessage = (TextView)findViewById(R.id.exchangeMessage);
//		mGetCoinMessage = (TextView)findViewById(R.id.getCoinMessage);
//		mExchangeBtn = (LinearLayout)findViewById(R.id.exchangeBtn);
//		mGetCoiBtn = (LinearLayout)findViewById(R.id.getCoinBtn);	
//		
//		
//		mListView = (LoadMoreListView)findViewById(R.id.myExchangeListView);
//		mListView.setVisibility(View.GONE);
//		mAdapter = new ListGiftCardAdapter(this);
//		mListView.setAdapter(mAdapter);
//		switchShowOrHideView(false, false);
//		initNotFoundAndLoadingView();
//		//reLoadData(false, true);
//	}
//
//	
//
//	public void reLoadData(boolean isReloadUserInfo, boolean isCheckUserCoins) {
//		try {
//			if (isReloadUserInfo) {
//				((HomeActivity) getApplicationContext()).loadUserInfo();
//			}
//			if (isCheckUserCoins) {				
//				loadListGiftCard();
//			}			
//			checkUserCoins();
//		} catch (Exception e) {
//		}
//	}
//
//	private void checkUserCoins() {
//		try {			
//			if (userCoins >= AppConfig.MIN_COIN_EXCHANGE) {
//				switchShowOrHideView(true, false);
//			} else {
//				switchShowOrHideView(false, true);
//			}
//		} catch (Exception e) {
//		}
//	}
//
//	
//	protected void initNotFoundAndLoadingView(){
//		mNotFoundData=(LinearLayout)findViewById(R.id.notFoundDataContainer);		
//		mWaitingForLoading=(LinearLayout)findViewById(R.id.waitingLoading);
//		mProgress=(ProgressWheel)findViewById(R.id.progressWheel);
//		mProgress.spin();
//		showNotFoundOrLoadingView(false, true);
//		mBtnRetry=(LinearLayout)findViewById(R.id.btnRetry);
//		//mTracker = EasyTracker.getInstance(getActivity());
//	}
//
//	private void switchShowOrHideView(boolean isShowExchange,
//			boolean isShowGetCoin) {
//		mExchangeContainer.setVisibility(isShowExchange ? View.VISIBLE
//				: View.GONE);
//		mGetCoinContainer.setVisibility(isShowGetCoin ? View.VISIBLE
//				: View.GONE);
//	}
//
//
//	private void changeMenu()
//	{
//		mExchangeActivity.setBackgroundResource(R.drawable.btn_over);
//		mExchangeHistory.setBackgroundResource(R.drawable.exchange_button_activity_background);
//		mExchangePointHistory.setBackgroundResource(R.drawable.exchange_button_activity_background);
//	}
//	private void initListener() {
//		//initRetryButtonListener();
//		mExchangeBtn.setOnClickListener(this);
//		mGetCoiBtn.setOnClickListener(this);
//		mListView.setOnLoadMoreListener(this);
//		//mBanner.setOnClickListener(this);
//	}
//	public void onClick(View v) {
//		switch (v.getId()) {
//		case R.id.btnRetry:
//			pageNo = 1;
//			mListView.setVisibility(View.VISIBLE);
//			showNotFoundOrLoadingView(false, true);
//			loadListGiftCard();
//			break;
//			default:
//				super.onClick(v);
//				break;
//		}
//	}
//	
//	private void loadListGiftCard() {
//		if (mLoadListGiftCard == null
//				|| mLoadListGiftCard.getStatus() == Status.FINISHED) {
//			mLoadListGiftCard = new LoadListGiftCard();
//			mLoadListGiftCard.execute();
//		}
//	}
//	private class LoadListGiftCard extends AsyncTask<Void, Void, List<ListGiftCardDTO>> {
//		@Override
//		protected void onPreExecute() {
//			super.onPreExecute();
//			showNotFoundOrLoadingView(false, true);
//			
//		}
//
//		@Override
//		protected List<ListGiftCardDTO> doInBackground(Void... params) {
//			try {
//				return ListGiftCardModel.getInstance().getListGiftCard(String.valueOf(pageNo));
//			} catch (Exception e) {
//				return null;
//			}
//		}
//		
//		@Override
//		protected void onPostExecute(List<ListGiftCardDTO> result) {
//			super.onPostExecute(result);
//			try {
//				if (result != null) {
//					if (result.size() < 1) {
//						if (mAdapter.getCount() < 1) {
//							showNotFoundOrLoadingView(false, false);
//							
//							mListView.setVisibility(View.GONE);
//						} else {
//							
//							showNotFoundOrLoadingView(false, false);
//							mListView.setVisibility(View.VISIBLE);
//						}						
//					} else {
//						if (pageNo == 1) {
//							mAdapter.updateAppList(result);
//						} else {
//							mAdapter.insertAppList(result);
//						}
//						pageNo++;
//						showNotFoundOrLoadingView(false, false);
//						mListView.setVisibility(View.VISIBLE);
//					}
//				} else {
//					if (mAdapter.getCount() < 1) {
//						showNotFoundOrLoadingView(true, false);
//						
//						mListView.setVisibility(View.GONE);
//					} else {
//						
//						showNotFoundOrLoadingView(false, false);
//						mListView.setVisibility(View.VISIBLE);
//					}
//				}
//			} catch (Exception e) {
//			}
//			mListView.onLoadMoreComplete();
//		}
//	}
//	@Override
//	public void onLoadMore() {
//		
//		loadListGiftCard();
//	}
//	
//	
//	protected void showNotFoundOrLoadingView(boolean isShowNotFound,boolean isShowLoading){
//		if(isShowNotFound){
//			mNotFoundData.setVisibility(View.VISIBLE);
//		}else{
//			mNotFoundData.setVisibility(View.GONE);
//		}
//		if(isShowLoading){
//			mWaitingForLoading.setVisibility(View.VISIBLE);
//		}else{
//			mWaitingForLoading.setVisibility(View.GONE);
//		}
//	}
//	@Override
//	public void onStart() {
//	    super.onStart();
//	    try {
//	    	EasyTracker.getInstance(this).activityStart(this);  // Add this method.
//		} catch (Exception e) {			
//		}
//	  }
//
//	  @Override
//	  public void onStop() {
//	    super.onStop();
//	    try {
//	    	EasyTracker.getInstance(this).activityStop(this);  // Add this method.
//		} catch (Exception e) {
//		}
//	  }	 
//	
//	
//}
